package nekocalc.gui;

import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;

import javax.swing.Action;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JTextField;
import javax.swing.SwingConstants;

import nekocalc.gui.action.NekoCalcMenuAction;

public class MainWindow extends JFrame {
	private JTextField textField;
	private NekoCalcMenuAction menuActions = null;
	public MainWindow() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setTitle("猫電卓 - NekoCalc");
		getContentPane().setLayout(null);
		
		menuActions = new NekoCalcMenuAction();
		
		JButton btn7 = new JButton("7");
		btn7.setBounds(10, 50, 100, 27);
		getContentPane().add(btn7);
		
		JButton btn8 = new JButton("8");
		btn8.setBounds(122, 50, 100, 27);
		getContentPane().add(btn8);
		
		JButton btn9 = new JButton("9");
		btn9.setBounds(234, 50, 100, 27);
		getContentPane().add(btn9);
		
		JButton btn4 = new JButton("4");
		btn4.setBounds(10, 89, 100, 27);
		getContentPane().add(btn4);
		
		JButton btn5 = new JButton("5");
		btn5.setBounds(122, 89, 100, 27);
		getContentPane().add(btn5);
		
		JButton btn6 = new JButton("6");
		btn6.setBounds(234, 89, 100, 27);
		getContentPane().add(btn6);
		
		JButton btn1 = new JButton("1");
		btn1.setBounds(10, 128, 100, 27);
		getContentPane().add(btn1);
		
		JButton btn2 = new JButton("2");
		btn2.setBounds(122, 128, 100, 27);
		getContentPane().add(btn2);
		
		JButton btn3 = new JButton("3");
		btn3.setBounds(234, 128, 100, 27);
		getContentPane().add(btn3);
		
		JButton btn0 = new JButton("0");
		btn0.setBounds(10, 167, 100, 27);
		getContentPane().add(btn0);
		
		JButton btnDot = new JButton(".");
		btnDot.setBounds(122, 167, 100, 27);
		getContentPane().add(btnDot);
		
		JButton btnEqual = new JButton("=");
		btnEqual.setBounds(234, 167, 100, 27);
		getContentPane().add(btnEqual);
		
		JButton btnPlus = new JButton("+");
		btnPlus.setBounds(346, 50, 100, 27);
		getContentPane().add(btnPlus);
		
		JButton btnMinus = new JButton("-");
		btnMinus.setBounds(346, 89, 100, 27);
		getContentPane().add(btnMinus);
		
		JButton btnMultiply = new JButton("×");
		btnMultiply.setBounds(346, 128, 100, 27);
		getContentPane().add(btnMultiply);
		
		JButton btnDivide = new JButton("÷");
		btnDivide.setBounds(346, 167, 100, 27);
		getContentPane().add(btnDivide);
		
		JButton btnC = new JButton("C");
		btnC.setBounds(10, 205, 100, 27);
		getContentPane().add(btnC);
		
		textField = new JTextField();
		textField.setFont(new Font("SansSerif", Font.BOLD, 12));
		textField.setHorizontalAlignment(SwingConstants.TRAILING);
		textField.setEditable(false);
		textField.setBackground(new Color(189, 183, 107));
		textField.setText("0");
		textField.setBounds(10, 11, 436, 28);
		getContentPane().add(textField);
		textField.setColumns(10);
		// TODO Auto-generated constructor stub
		setMinimumSize(new Dimension(472, 300));
		pack();
		
		JMenuBar menuBar = new JMenuBar();
		setJMenuBar(menuBar);
		
		JMenu mnFile = new JMenu("File");
		menuBar.add(mnFile);
		
		JMenuItem mntmQuit = new JMenuItem(menuActions.fileQuit);
		mnFile.add(mntmQuit);
		
		JMenu mnEdit = new JMenu("Edit");
		menuBar.add(mnEdit);
		
		JMenuItem mntmCut = new JMenuItem(menuActions.editCut);
		mnEdit.add(mntmCut);
		
		JMenuItem mntmCopy = new JMenuItem(menuActions.editCopy);
		mnEdit.add(mntmCopy);
		
		JMenuItem mntmPaste = new JMenuItem(menuActions.editPaste);
		mnEdit.add(mntmPaste);
		
		Component horizontalGlue = Box.createHorizontalGlue();
		menuBar.add(horizontalGlue);
		
		JMenu mnHelp = new JMenu("Help");
		menuBar.add(mnHelp);
		
		JMenuItem mntmAbout = new JMenuItem(menuActions.helpAbout);
		mnHelp.add(mntmAbout);
	}
}
